package com.bingxue.edu.framework.mybatis.query;

import com.mybatisflex.annotation.TableRef;
import lombok.Data;

/**
 * @author panbo
 * @since 2024/7/1
 */
@Data
@TableRef(User.class)
public class UserQuery {
    /**
     * 不加QueryCondition注解，默认根据字段名进行EQ查询
     */
    private Integer id;

    /**
     * 根据字段名和type进行like查询
     */
    @Query(type = QueryType.LIKE)
    private String name;

    /**
     * 指定字段名称
     */
    @Query(type = QueryType.LT, field = "age")
    private Integer userAge;

    /**
     * 测试空值跳过
     */
    @Query(type = QueryType.LIKE, field = "age")
    private Integer nullValue;

    /**
     * 多个QueryCondition 将会进行or查询
     * join指定关联查询条件
     */
    @Query(type = QueryType.LIKE, field = "departmentName", join = @Join(target = Department.class, selfField = "deptId", targetField = "id"))
    @Query(type = QueryType.EQ, field = "roleName", join = @Join(target = Role.class, selfField = "roleId"))
    private String keyword;
}
